package com.prs.crm.action.person;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.action.ReportAction;
import com.prs.crm.domain.person.Department;
import com.prs.crm.domain.person.Dossier;
import com.prs.crm.domain.person.PostSet;
import com.prs.crm.domain.person.StaffSex;
import com.prs.crm.domain.person.StaffState;
import com.prs.crm.report.ExportConfig;
import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;

public class PersonReportAction extends ReportAction{

	private static final long serialVersionUID = 1L;
	private Department department;
	private PostSet postSet;
	private StaffSex staffSex;
	private StaffState staffState;

	public StaffSex getStaffSex() {
		return staffSex;
	}
	public void setStaffSex(StaffSex staffSex) {
		this.staffSex = staffSex;
	}
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	public PostSet getPostSet() {
		return postSet;
	}
	public void setPostSet(PostSet postSet) {
		this.postSet = postSet;
	}
	public StaffState getStaffState() {
		return staffState;
	}
	public void setStaffState(StaffState staffState) {
		this.staffState = staffState;
	}
	@Action(value = "exportDossierReport", results = { @Result(name = "success", type = "stream", params = {
			"contentType", "${contentType}", "inputName", "inputStream",
			"bufferSize", "1024", "contentDisposition",
			"filename=${outfileName}" }) })
	public String reportOrder() {
		ReportTable table=new ReportTable("档案管理");
		department=new Department();
		postSet=new PostSet();
		staffSex=new StaffSex();
		staffState=new StaffState();
		table.addCell(new ReportCell("序号","id"));
		table.addCell(new ReportCell("工号","jobNumber"));
		table.addCell(new ReportCell("姓名","name"));
		table.addCell(new ReportCell("性别","staffSex.name"));
		table.addCell(new ReportCell("部门","department.name"));
		table.addCell(new ReportCell("岗位","postSet.name"));
		table.addCell(new ReportCell("状态","staffState.name"));
		table.addCell(new ReportCell("办公地址","workAdress"));
		table.addCell(new ReportCell("办公电话","workPhone"));
		table.addCell(new ReportCell("家庭地址","familyAdress"));
		table.addCell(new ReportCell("家庭电话","familyPhone"));
		table.addCell(new ReportCell("劳动保险号","ldbxNum"));
		table.addCell(new ReportCell("医疗保险号","ylbxNum"));
		table.addCell(new ReportCell("工伤参保日期","gsTime"));
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(Dossier.class);
		this.setOutFilePath(this.getReportService().exportAlreadyDistribution(criteria, table, new ExportConfig(), this.getExportType()));
		return SUCCESS;
	}
}	
